#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 2e5 + 10;

int n, q;
int num[N], idx[N];

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> q;
    for(int i = 1; i <= n; i ++){
        num[i] = i;
        idx[i] = i;
    }
    
    for(int i = 1, x; i <= q; i ++){
        cin >> x;
        int index = idx[x];

        if(index == n){
            int ne = num[index - 1];   // ne所在的位置
            swap(num[index], num[index - 1]);
            swap(idx[x], idx[ne]);
        }else{
            int ne = num[index + 1];
            swap(num[index], num[index + 1]);
            swap(idx[x], idx[ne]);
        }



    }


    for(int i = 1; i <= n; i ++){
        cout << num[i] << " ";
    }


    return 0;
}